<?php
include 'checkLogin.php';
@$img = $_REQUEST['file'];
@$name = $_REQUEST['name'];
@$age = $_REQUEST['age'];
@$sex = $_REQUEST['sex'];
@$phone = $_REQUEST['phone'];
@$location = $_REQUEST['location'];
@$branch_id = $_REQUEST['branch_id'];
//move_uploaded_file($img['tmp_name'], 'img/worker/'.$img['name']);

if(empty($name)||empty($age)||empty($sex)||empty($phone)||empty($location)){
	$mes = "都不能为空";
	include 'addWorker.php';
	die;
}
include 'db/li.php';
@$flog = dbInsert('insert into worker(name,sex,age,phone,location,in_date,role_id,branch_id) value(:name,:sex,:age,:phone,:location,now(),5,:branch_id)',
					array('name'=>$name,'sex'=>$sex,'age'=>$age,'phone'=>$phone,'location'=>$location,'branch_id'=>$branch_id));
if(!$flog){
	$mes = "添加职员失败";
	include 'addWorker.php';
	die;
}
header('Refresh:0;url=index.php');